package com.yztc.ui.classifydetail;

import android.content.Context;
import android.util.Log;

import com.yztc.bean.classifydetail.ClassifyDetailBean;
import com.yztc.bean.classifydetail.ClassifyDetailHeaderBean;
import com.yztc.ui.classifydetail.config.ClassifyDetailUrlConfig;

import java.util.Map;

/**
 * Created by MengLingzhang on 2016/10/10.
 */
public class ClassifyDetailPresenter implements ClassifyDetailContract.Presenter{
    private ClassifyDetailContract.View view;
    private ClassifyDetailModle modle;
    private Map<String,String> map;
    private int id;

    public ClassifyDetailPresenter(ClassifyDetailContract.View view,Map<String,String> map,int id){
        Log.i("tag","%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
        this.view=view;
        this.map=map;
        this.id=id;
        this.modle=new ClassifyDetailModle();
        Log.i("tag","%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2");
    }

    @Override
    public void getVerticalClassifyDetailHeaderBean(Context context) {
        modle.getVerticalClassifyDetailHeaderBean(ClassifyDetailUrlConfig.Path.BASE_URL, id, new ClassifyDetailContract.OnLoadListenerHeader() {
            @Override
            public void onSuccess(ClassifyDetailHeaderBean ClassifyDetailHeaderBean) {
                Log.i("tag","################################5");
                view.OnGetVerticalClassifyDetailHeaderBean(ClassifyDetailHeaderBean);
                view.OnGetVerticalClassifyDetailHeaderActlistBean(ClassifyDetailHeaderBean.getActlist());
                view.OnGetVerticalClassifyDetailHeaderSecondlevelBean(ClassifyDetailHeaderBean.getSecondlevel());
            }

            @Override
            public void onFailure(Throwable e) {
                Log.i("tag","################################6");
                view.onGetVerticalFailed(e);
            }
        });
    }

    @Override
    public void getVerticalClassifyProductListBean(Context context) {
        modle.getVerticalClassifyDetailBean(ClassifyDetailUrlConfig.Path.BASE_URL,map,new ClassifyDetailContract.OnLoadListener(){

            @Override
            public void onSuccess(ClassifyDetailBean classifyDetailBean) {
                Log.i("tag","################################3");
                view.onGetVerticalClassifyProductListBean(classifyDetailBean.getProductList());
            }

            @Override
            public void onFailure(Throwable e) {
                Log.i("tag","################################4");
                view.onGetVerticalFailed(e);
            }
        });
    }
}
